package com.chixing.service.impl;

import com.chixing.mapper.OrdersMapper;
import com.chixing.pojo.Orders;
import com.chixing.service.OrderService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrdersMapper ordersMapper;
    @Override
    public ServerResponse save(Orders orders) {
        int a=ordersMapper.insert(orders);
        if(a==1){
            return ServerResponse.getDataSuccess(orders);
        }
        return ServerResponse.deleteDataFailue("订单创建失败");
    }

    @Override
    public Orders getById(Integer id) {
        return ordersMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Orders> getAll() {
        return ordersMapper.selectByExample(null);
    }
}
